<?php

namespace app\im\controller;

use app\im\service\ChatRoomService;

/**
 * 聊天室
 */
class ChatRoom extends Controller
{
    protected $service;

    public function init()
    {
        $this->service = new ChatRoomService();
    }

    /**
     * 消息列表
     */
    public function messages()
    {
        $roomId = input('room_id');
        $messages = $this->service->messages($roomId);

        return resp_success($messages);
    }

    /**
     * 发送消息
     */
    public function send_message()
    {
        $roomId = input('room_id', 0);
        $msg = input('msg', '');
        $res = $this->service->sendMessage($roomId, get_curr_user_id(), $msg);
        return resp_success([]);
    }
}
